<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function deepCopy (obj) {
          let copy = obj
          if ( Array.isArray(copy) ) {
            // 为数组
            copy = obj.map(item => deepCopy(item))
          } else if ( typeof obj === 'object' &&  !(copy instanceof Function) ) {
            // 为对象且不为函数
            copy = {}
            Object.keys(obj).forEach(key => copy[key] = deepCopy(obj[key]))
          }
          return copy
        }
        let obj = {
          a: {
            c: 10
          },
          arr: [1,2,3,4,5,6,7,8,9,10],
          fn () {
            console.log(123)
          }
        }
        let cc = deepCopy(obj)
        console.log(cc)
    </script>
</body>
</html>